#include "sort.h"

void CountSort(vector<int>& vc){
  int min = vc[0];
  int max = vc[0];
  for(int e : vc){
    if(e < min)
    {
      min = e;
    }
    if(e > max)
    {
      max = e;
    }
  }
  int range = max - min + 1;
  vector<int> tmp;
  tmp.resize(range);
  for(int e : vc)
  {
    ++tmp[e-min];
  }

  int k = 0;
  for(int i = 0; i<tmp.size(); ++i)
  {
    while(tmp[i]--)
    {
      vc[k++] = i+min;
    }
  }
}
